
#include "EngineLib.h"

#include "Test.h"

#include <stdio.h>
#include <time.h>

using namespace EngineLib;

void outputMatrix44(const Matrix44 &m)
{
	printf("%g\t%g\t%g\t%g\n", m.m11, m.m12, m.m13, m.m14);
	printf("%g\t%g\t%g\t%g\n", m.m21, m.m22, m.m23, m.m24);
	printf("%g\t%g\t%g\t%g\n", m.m31, m.m32, m.m33, m.m34);
	printf("%g\t%g\t%g\t%g\n", m.m41, m.m42, m.m43, m.m44);
}

static clock_t lastclock;
void clockstart(void) 
{
	lastclock = clock();
}
void clocktime(bool restart = true)
{
	clock_t now = clock();
	printf("cost: %dms\n", now - lastclock);
	if (restart)
		lastclock = now;
}

int main(int argc, char *argv[])
{
	Clock::StartUp();
	LogManagement::StartUp();
	MemoryManagement::StartUp();
	ContainerManagement::StartUp();
	GameConfig::StartUp();

/*
	printf("[System] %d\n", String::Interning("[System]"));
	printf("[P1_Key] %d\n", String::Interning("[P1_Key]"));
	printf("[P2_Key] %d\n", String::Interning("[P2_Key]"));
	printf("[P1_Joy] %d\n", String::Interning("[P1_Joy]"));
	printf("[P2_Joy] %d\n", String::Interning("[P2_Joy]"));
	printf("FullScreen %d\n", String::Interning("FullScreen"));
	printf("WideScreen %d\n", String::Interning("WideScreen"));
	printf("VerticalSync %d\n", String::Interning("VerticalSync"));
	printf("ShowFPS %d\n", String::Interning("ShowFPS"));
	
	printf("MusicVolume %d\n", String::Interning("MusicVolume"));
	printf("SoundVolume %d\n", String::Interning("SoundVolume"));
	
	printf("ScreenWidth %d\n", String::Interning("ScreenWidth"));
	printf("ScreenHeight %d\n", String::Interning("ScreenHeight"));
	printf("MSAA %d\n", String::Interning("MSAA"));
	printf("Gamma %d\n", String::Interning("Gamma"));
	printf("ArrowUp %d\n", String::Interning("ArrowUp"));
	printf("ArrowDown %d\n", String::Interning("ArrowDown"));
	printf("ArrowLeft %d\n", String::Interning("ArrowLeft"));
	printf("ArrowRight %d\n", String::Interning("ArrowRight"));
	printf("ButtonA %d\n", String::Interning("ButtonA"));
	printf("ButtonB %d\n", String::Interning("ButtonB"));
	printf("ButtonX %d\n", String::Interning("ButtonX"));
	printf("ButtonY %d\n", String::Interning("ButtonY"));
	printf("ButtonL %d\n", String::Interning("ButtonL"));
	printf("ButtonR %d\n", String::Interning("ButtonR"));
	printf("Start %d\n", String::Interning("Start"));
	printf("Select %d\n", String::Interning("Select"));
*/
	RunTest();

	GameConfig::ShutDown();
	ContainerManagement::ShutDown();
	MemoryManagement::ShutDown();
	LogManagement::ShutDown();
	Clock::ShutDown();
	return 0;
	
	Matrix44 mm1, mm2, mm3;
	int n;

	mm1.m11 = 2.0f; mm1.m12 = 2.0f; mm1.m21 = 2.0f; mm1.m22 = 3.0f;
	mm1.m33 = 4.0f;
	mm1.m41 = mm1.m42 = mm1.m43 = 10.0f;

	mm2.m11 = 2.0f; mm2.m22 = 3.0f; mm2.m33 = 4.0f;

	n = 10000000;
	printf("\nMat44 multiply 10,000,000 times\n");
	clockstart();
	while(n--)
		Matrix44::Multiply(mm1, mm2, mm3);
	clocktime();

	n = 10000000;
	printf("\nMat44 transpose 10,000,000 times\n");
	clockstart();
	while(n--)
		mm1.Transpose();
	clocktime();

	mm1.m11 = mm1.m12 = mm1.m13 = mm1.m14 = 
	mm1.m21 = mm1.m22 = mm1.m23 = mm1.m24 =
	mm1.m31 = mm1.m32 = mm1.m33 = mm1.m34 =
	mm1.m41 = mm1.m42 = mm1.m43 = mm1.m44 = 1.000000001f;

	mm2 = mm1;

	n = 10000000;
	printf("\nMat44 multiply self 10,000,000 times\n");
	clockstart();
	while(n--)
		mm1.MultiplyBy(mm2);
	clocktime();

	/*
	printf("m1: \n");
	outputMatrix34(m1);
	printf("\nm2: \n");
	outputMatrix34(m2);
	printf("\nm3: \n");
	outputMatrix34(m3);
	*/
	/*
	printf("sizeof Vector2d: %d \n", sizeof(Vector2d));
	printf("sizeof Vector3d: %d \n", sizeof(Vector3d));
	printf("sizeof Vector4d: %d \n", sizeof(Vector4d));
	
	printf("sizeof Matrix34: %d \n", sizeof(Matrix34));
	printf("sizeof Matrix44: %d \n", sizeof(Matrix44));
	*/
	return 0;
}